package com.xuyuan.spring.auto.in;

import org.springframework.context.annotation.ImportSelector;
import org.springframework.core.type.AnnotationMetadata;
import org.springframework.util.StringUtils;

import java.util.Arrays;
import java.util.function.Predicate;

/**
 * 自定义ImportSelector
 *
 * @author xuyuan
 */
public class CustomImportSelector implements ImportSelector {

    /**
     * importingClassMetadata:@Import标注的类信息
     *
     * @param importingClassMetadata
     * @return
     */
    @Override
    public String[] selectImports(AnnotationMetadata importingClassMetadata) {
        return StringUtils.toStringArray(Arrays.asList("com.xuyuan.spring.auto.AutoExample2"));
    }

    @Override
    public Predicate<String> getExclusionFilter() {
        return ImportSelector.super.getExclusionFilter();
    }
}
